package model.letter;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;

import model.admin.OptionalServiceVO;
import model.member.MemberVO;

import com.ibatis.sqlmap.client.SqlMapClient;

public class LetterDao {
	private SqlMapClient sqlMapClient;
	public LetterDao(SqlMapClient sqlMapClient){
		this.sqlMapClient=sqlMapClient;
	}
	public void letterWrite(LetterVO lvo) throws SQLException {
		sqlMapClient.insert("letter.letterWrite",lvo);
	}
	public List<LetterVO> letterList(HashMap map) throws SQLException {
		return sqlMapClient.queryForList("letter.letterList",map);
	}
	public Integer getTotalLetter(int optionalNo) throws SQLException{
		return (Integer) sqlMapClient.queryForObject("letter.getTotalLetter",optionalNo);
	}
	public LetterVO getLetter(LetterVO lvo) throws SQLException {
		return (LetterVO) sqlMapClient.queryForObject("letter.getLetter",lvo);
	}
	public void updateLetter(LetterVO lvo) throws SQLException {
		sqlMapClient.update("letter.updateLetter",lvo);
	}
	public void deleteLetter(LetterVO lvo) throws SQLException {
		sqlMapClient.delete("letter.deleteLetter",lvo);
	}
	public OptionalServiceVO letterRequest(String id) throws SQLException {
		return (OptionalServiceVO) sqlMapClient.queryForObject("optionalService.letterRequest", id);
	}
	public OptionalServiceVO existByOptionalNo(MemberVO mvo) throws SQLException {
		return (OptionalServiceVO) sqlMapClient.queryForObject("optionalService.requestChecked", mvo);
	}
	public String getImg(MemberVO mvo) throws SQLException {
		return (String) sqlMapClient.queryForObject("happy.getfile",mvo);
	}
}
